//
//  NMPOHomeViewController.swift
//  NMPO
//
//  Created by PowerfullClean on 2023/10/31.
//

import UIKit

class NMPOHomeViewController: NMPOBaseCollectionViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
//        NMPOManager.nmpo_manager.nmpo_configVpnAuth()
        NMPOManager.nmpo_manager.nmpo_configLocManager()
        NMPOManager.nmpo_manager.nmpo_requesAuthLocation()
    }
    // MARK: - nmpo action
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        nmpo_collectionView.reloadData()
    }
    override func nmpo_collectionViews() {
        view.addSubview(nmpo_bottomView)
        super.nmpo_collectionViews()
        view.addSubview(nmpo_navView)
        nmpo_collectionView.snp.makeConstraints { make in
            make.bottom.width.left.equalToSuperview()
            make.top.equalTo(nmpo_navView.snp.bottom)
        }
        nmpo_bottomView.snp.makeConstraints { make in
            make.bottom.left.width.equalToSuperview()
            make.height.equalTo(nmpo_SCREEN_HEIGHT/2.0)
        }
        nmpo_collectionView.register(NMPOHomCell.classForCoder(), forCellWithReuseIdentifier: NMPOHomCell.nmpo_viewToString)
        nmpo_collectionView.dataSource = self
        nmpo_collectionView.delegate = self
        
    }
    // MARK: - nmpo lazy
    override func nmpo_baseBgName() -> String? {
        return "nmpo_home_bg"
    }
    lazy var nmpo_navView: NMPOHomeNavView = {
        let nmpo_navView = NMPOHomeNavView()
        return nmpo_navView
    }()
    lazy var nmpo_bottomView: UIImageView = {
        let nmpo_bottomView = UIImageView(image: UIImage(named: "nmpo_home_bottom"))
        return nmpo_bottomView
    }()
}

extension NMPOHomeViewController: UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return 1
    }
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let nmpo_cell = collectionView.dequeueReusableCell(withReuseIdentifier: NMPOHomCell.nmpo_viewToString, for: indexPath) as! NMPOHomCell
        nmpo_cell.nmpo_reloadSpeedValue()
        nmpo_cell.nmpo_reloadIpShow()
        return nmpo_cell
    }
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
        return CGSize(width: nmpo_SCREEN_WIDTH, height: 500+163)
    }
}

